package com.wisemoresystem.seal.action.config.verify;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.base.tip.Tip;
import com.wisemoresystem.seal.model.t_d_verify_config;
import com.wisemoresystem.seal.service.VerifyConfigService;
import com.wisemoresystem.seal.web.WebTools;

/**
 * 换人复核开关
 * 
 * @author Administrator
 *
 */
@Controller("configverify")
@Scope("prototype")
@RequestMapping("/ix/config/verify")
public class VerifyConfigAction extends ProjBaseAction {
	@Autowired
	private VerifyConfigService configservice;

	/**
	 * 换人复合列表
	 * 
	 * @return
	 */
	@RequestMapping("list")
	public ModelAndView list() {
		List<Map<String, Object>> list = configservice.selectVerifyConfig();

		ModelAndView mv = new ModelAndView("jsp/config/verify/list");
		mv.addObject("list", list);

		return mv;
	}

	/**
	 * 换人复核开关配置
	 * 
	 * @param verifyconfig_id
	 *            换人复核配置id
	 * @param flag
	 *            状态
	 * @return
	 */
	@RequestMapping("config")
	public ModelAndView config(String verifyconfig_id, String flag) {
		t_d_verify_config verifyconfig = (t_d_verify_config) oc.findObjById(
				verifyconfig_id, t_d_verify_config.class);

		if ("开启".equals(flag.trim())) {
			flag = "关闭";
			verifyconfig.setFlag(flag);
			oc.saveObj(verifyconfig);
			super.setTipMsg("关闭成功", Tip.Type.success);
			logT.logH("开启" + verifyconfig.getName() + "换人复核开关",
					t_d_verify_config.class, verifyconfig.get_id());
		} else {
			flag = "开启";
			verifyconfig.setFlag(flag);
			oc.saveObj(verifyconfig);
			super.setTipMsg("开启成功", Tip.Type.success);
			logT.logH("关闭" + verifyconfig.getName() + "换人复核开关",
					t_d_verify_config.class, verifyconfig.get_id());
		}
		verifyconfig.setUser_id(WebTools.getCurrentUserId());

		ModelAndView mv = new ModelAndView("redirect:list.htm");
		return mv;
	}
}
